package com.mifan.controller;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mifan.common.Results;
import com.mifan.entity.Resources;
import com.mifan.mapper.ResourceMapper;
import com.mifan.service.IResourceService;
import com.mifan.vo.ResourceListVo;
import com.mifan.vo.ResultData;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.parameters.P;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 资源表 前端控制器
 * </p>
 *
 * @author Milan
 * @since 2024-09-13
 */
@RestController
@RequestMapping("/resource")
public class ResourceController {

    @Resource
    private ResourceMapper resourceMapper;



//    @PreAuthorize("hasAuthority('resource:list')")
    @GetMapping("/list")
    public Results list(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<ResourceListVo> resourcesVo = resourceMapper.selectListWithMenu();
        PageInfo page = new PageInfo(resourcesVo);
        ResultData resultData = ResultData.createResultData(page);
        return Results.success(resultData);
    }
}
